﻿using B.S.DataBase.MyProject.Domain;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using B.S.DataBase.MyRead.API.Appicant.Command.RoleMenus;
using B.S.DataBase.MyRead.API.Appicant.Command.Menus;
using MediatR;

namespace B.S.DataBase.MyRead.API.Appicant.CommandHandler.RoleMenus
{
    public class GetMenuNameCommendHandlers : IRequestHandler<GetMenuNameCommends, APIResult<List<Menu>>>
    {
        private readonly IBaseRepository<Menu> menuRepos;

        public GetMenuNameCommendHandlers(IBaseRepository<Menu> menuRepos)
        {
            this.menuRepos = menuRepos;
        }


        /// <summary>
        /// 查询菜单名称
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<APIResult<List<Menu>>> Handle(GetMenuNameCommends request, CancellationToken cancellationToken)
        {
            APIResult<List<Menu>> result = new APIResult<List<Menu>>();
            result.Code = APIEnum.查询成功;
            result.Msg=APIEnum.查询成功.ToString();
            var list = menuRepos.GetAll();
            result.data = list.ToList();
            return await Task.FromResult(result);
        }
    }
}
